#!/bin/bash

# install some common tools
yum install -y unzip
yum install -y wget
yum install -y expect
yum install -y net-tools
yum install -y lrzsz
yum install -y zip

# install package dependency
yum install -y yum-utils device-mapper-persistent-data lvm2



# check whether docker is installed
docker version
if [ $? == 0 ];then
	echo "docker already installed,Nothong to do"
else

# uninstall old docker
# yum remove docker \
                  # docker-client \
                  # docker-client-latest \
                  # docker-common \
                  # docker-latest \
                  # docker-latest-logrotate \
                  # docker-logrotate \
                  # docker-engine

# config Aliyun repo, you may need to vim /usr/bin/yum-config-manager, and then change python → python2 at first line.
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
    # https://download.docker.com/linux/centos/docker-ce.repo

# install latest docker
yum install -y docker-ce docker-ce-cli containerd.io

# start docker and enable docker at boot time
systemctl start docker
systemctl enable docker

# 把阿里云的mirror配置到docker，docker pull的速度变快
cd /etc/docker/
cat>daemon.json<<EOF
{
  "registry-mirrors": ["https://n1s5gkfw.mirror.aliyuncs.com"]
}
EOF
docker version
if [ $? == 0 ];then
	echo "docker installed successfully"
fi

fi

